home *** CD-ROM | disk | FTP | other *** search
/ Software of the Month Club 2000 October / Software of the Month - Ultimate Collection Shareware 277.iso / pc / PROGRAMS / UTILITY / WINLINUX / DATA1.CAB / programs_-_include / LINUX / APM_BIOS.H < prev    next >
C/C++ Source or Header  |  1999-09-17  |  4KB  |  144 lines

  1. #ifndef _LINUX_APM_H
  2. #define _LINUX_APM_H
  3.  
  4. /*
  5.  * Include file for the interface to an APM BIOS
  6.  * Copyright 1994-1998 Stephen Rothwell (Stephen.Rothwell@canb.auug.org.au)
  7.  *
  8.  * This program is free software; you can redistribute it and/or modify it
  9.  * under the terms of the GNU General Public License as published by the
  10.  * Free Software Foundation; either version 2, or (at your option) any
  11.  * later version.
  12.  *
  13.  * This program is distributed in the hope that it will be useful, but
  14.  * WITHOUT ANY WARRANTY; without even the implied warranty of
  15.  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
  16.  * General Public License for more details.
  17.  */
  18.  
  19. typedef unsigned short    apm_event_t;
  20. typedef unsigned short    apm_eventinfo_t;
  21.  
  22. #ifdef __KERNEL__
  23.  
  24. #define APM_40        0x40
  25. #define APM_CS        (APM_40 + 8)
  26. #define APM_CS_16    (APM_CS + 8)
  27. #define APM_DS        (APM_CS_16 + 8)
  28.  
  29. struct apm_bios_info {
  30.     unsigned short    version;
  31.     unsigned short    cseg;
  32.     unsigned long    offset;
  33.     unsigned short    cseg_16;
  34.     unsigned short    dseg;
  35.     unsigned short    flags;
  36.     unsigned short    cseg_len;
  37.     unsigned short    cseg_16_len;
  38.     unsigned short    dseg_len;
  39. };
  40.  
  41.                 /* Results of APM Installation Check */
  42. #define APM_16_BIT_SUPPORT    0x0001
  43. #define APM_32_BIT_SUPPORT    0x0002
  44. #define APM_IDLE_SLOWS_CLOCK    0x0004
  45. #define APM_BIOS_DISABLED          0x0008
  46. #define APM_BIOS_DISENGAGED     0x0010
  47.  
  48. /*
  49.  * Maximum number of events stored
  50.  */
  51. #define APM_MAX_EVENTS        20
  52.  
  53. /*
  54.  * The per-file APM data
  55.  */
  56. struct apm_bios_struct {
  57.     int        magic;
  58.     struct apm_bios_struct *    next;
  59.     int        suser;
  60.     int        suspends_pending;
  61.     int        standbys_pending;
  62.     int        suspends_read;
  63.     int        standbys_read;
  64.     int        event_head;
  65.     int        event_tail;
  66.     apm_event_t    events[APM_MAX_EVENTS];
  67. };
  68.  
  69. /*
  70.  * The magic number in apm_bios_struct
  71.  */
  72. #define APM_BIOS_MAGIC        0x4101
  73.  
  74. /*
  75.  * in init/main.c
  76.  */
  77. extern struct apm_bios_info    apm_bios_info;
  78.  
  79. extern void        apm_bios_init(void);
  80. extern void        apm_setup(char *, int *);
  81.  
  82. extern int        apm_register_callback(int (*callback)(apm_event_t));
  83. extern void        apm_unregister_callback(int (*callback)(apm_event_t));
  84.  
  85. extern void        apm_power_off(void);
  86. extern int        apm_display_blank(void);
  87. extern int        apm_display_unblank(void);
  88.  
  89. #endif    /* __KERNEL__ */
  90.  
  91. /*
  92.  * Power states
  93.  */
  94. #define APM_STATE_READY        0x0000
  95. #define APM_STATE_STANDBY    0x0001
  96. #define APM_STATE_SUSPEND    0x0002
  97. #define APM_STATE_OFF        0x0003
  98. #define APM_STATE_BUSY        0x0004
  99. #define APM_STATE_REJECT    0x0005
  100.  
  101. /*
  102.  * Events (results of Get PM Event)
  103.  */
  104. #define APM_SYS_STANDBY        0x0001
  105. #define APM_SYS_SUSPEND        0x0002
  106. #define APM_NORMAL_RESUME    0x0003
  107. #define APM_CRITICAL_RESUME    0x0004
  108. #define APM_LOW_BATTERY        0x0005
  109. #define APM_POWER_STATUS_CHANGE    0x0006
  110. #define APM_UPDATE_TIME        0x0007
  111. #define APM_CRITICAL_SUSPEND    0x0008
  112. #define APM_USER_STANDBY    0x0009
  113. #define APM_USER_SUSPEND    0x000a
  114. #define APM_STANDBY_RESUME    0x000b
  115. #define APM_CAPABILITY_CHANGE   0x000c
  116.  
  117. /*
  118.  * Error codes
  119.  */
  120. #define APM_SUCCESS        0x00
  121. #define APM_DISABLED        0x01
  122. #define APM_CONNECTED        0x02
  123. #define APM_NOT_CONNECTED    0x03
  124. #define APM_16_CONNECTED    0x05
  125. #define APM_16_UNSUPPORTED    0x06
  126. #define APM_32_CONNECTED    0x07
  127. #define APM_32_UNSUPPORTED    0x08
  128. #define APM_BAD_DEVICE        0x09
  129. #define APM_BAD_PARAM        0x0a
  130. #define APM_NOT_ENGAGED        0x0b
  131. #define APM_BAD_FUNCTION        0x0c
  132. #define APM_RESUME_DISABLED    0x0d
  133. #define APM_BAD_STATE        0x60
  134. #define APM_NO_EVENTS        0x80
  135. #define APM_NOT_PRESENT        0x86
  136.  
  137. /* ioctl operations */
  138. #include <linux/ioctl.h>
  139.  
  140. #define APM_IOC_STANDBY        _IO('A', 1)
  141. #define APM_IOC_SUSPEND        _IO('A', 2)
  142.  
  143. #endif    /* LINUX_APM_H */
  144.